/*   
 * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved.   
 *   
 * This software is the confidential and proprietary information of   
 * Founder. You shall not disclose such Confidential Information   
 * and shall use it only in accordance with the terms of the agreements   
 * you entered into with Founder.   
 *   
 */
package com.wujw.auto.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * 数据库类型处理工具类
 * 
 * @author wujw
 * @version 1.0, 2017年11月10日
 */
public class DataTypeUtil {
    public static String getType(String dataType) {
        String type = "";
        if ("tinyint".equals(StringUtils.substringBefore(dataType, "(")) || "tinyint".equalsIgnoreCase(dataType)) {
            type = "Byte";
        }
        if ("smallint".equals(StringUtils.substringBefore(dataType, "(")) || "smallint".equalsIgnoreCase(dataType)) {
            type = "Short";
        }
        if ("mediumint".equals(StringUtils.substringBefore(dataType, "(")) || "mediumint".equalsIgnoreCase(dataType)) {
            type = "Integer";
        }
        if ("int".equals(StringUtils.substringBefore(dataType, "(")) || "int".equalsIgnoreCase(dataType)) {
            type = "Integer";
        }
        if ("integer".equals(StringUtils.substringBefore(dataType, "(")) || "integer".equalsIgnoreCase(dataType)) {
            type = "Integer";
        }
        if ("bigint".equals(StringUtils.substringBefore(dataType, "(")) || "bigint".equalsIgnoreCase(dataType)) {
            type = "Long";
        }
        if ("bit".equals(StringUtils.substringBefore(dataType, "(")) || "bit".equalsIgnoreCase(dataType)) {
            type = "Boolean";
        }
        if ("double".equals(StringUtils.substringBefore(dataType, "(")) || "double".equalsIgnoreCase(dataType)) {
            type = "Double";
        }
        if ("float".equals(StringUtils.substringBefore(dataType, "(")) || "float".equalsIgnoreCase(dataType)) {
            type = "Float";
        }
        if ("decimal".equals(StringUtils.substringBefore(dataType, "(")) || "decimal".equalsIgnoreCase(dataType)) {
            type = "Long";
        }
        if ("char".equals(StringUtils.substringBefore(dataType, "(")) || "char".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("varchar".equals(StringUtils.substringBefore(dataType, "(")) || "varchar".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("varchar2".equals(StringUtils.substringBefore(dataType, "(")) || "varchar2".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("date".equals(StringUtils.substringBefore(dataType, "(")) || "date".equalsIgnoreCase(dataType)) {
            type = "Date";
        }
        if ("time".equals(StringUtils.substringBefore(dataType, "(")) || "time".equalsIgnoreCase(dataType)) {
            type = "Date";
        }
        if ("year".equals(StringUtils.substringBefore(dataType, "(")) || "year".equalsIgnoreCase(dataType)) {
            type = "Date";
        }
        if ("timestamp".equals(StringUtils.substringBefore(dataType, "(")) || "timestamp".equalsIgnoreCase(dataType)) {
            type = "Timestamp";
        }
        if ("datetime".equals(StringUtils.substringBefore(dataType, "(")) || "datetime".equalsIgnoreCase(dataType)) {
            type = "Timestamp";
        }
        if ("tinytext".equals(StringUtils.substringBefore(dataType, "(")) || "tinytext".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("enum".equals(StringUtils.substringBefore(dataType, "(")) || "enum".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("set".equals(StringUtils.substringBefore(dataType, "(")) || "set".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("text".equals(StringUtils.substringBefore(dataType, "(")) || "text".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("mediumtext".equals(StringUtils.substringBefore(dataType, "(")) || "mediumtext".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        if ("longtext".equals(StringUtils.substringBefore(dataType, "(")) || "longtext".equalsIgnoreCase(dataType)) {
            type = "String";
        }
        return type;
    }
}
